<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/common/backcommon.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Breaking Fast</title>
		<script type="text/javascript">
	        function loadPage(totalCount, pageSize, pageCurrent) {
		        $("#page").smartpaginator({
                    totalrecords: totalCount, 
                    recordsperpage: pageSize, 
                    initval: pageCurrent,  
                    next: '下一页', 
                    prev: '上一页', 
                    first: '第一页', 
                    last: '最后一页', 
                    theme: 'black', 
                    go: 'Go',
                    onchange: onPageChange
				});
	        };
			
			function onPageChange(newPageValue) {
				//获取查询参数
				var orderId = $("#orderId").val();
				var name = $("#name").val();
				var datatype = $("#datatype").val();
				var priceMax = $("#priceMax").val();
				var priceMin = $("#priceMin").val();
				var params = {
					orderId : orderId,
					name : name,
					datatype : datatype,
					priceMax : priceMax,
					priceMin : priceMin,
					pageNumber : newPageValue
				};
				var dataTr = $("#pageList tr");
				for(var i = 0; i < dataTr.length; i++) {
					if(i != 0) {
						$(dataTr[i]).remove();
					}
				}
				$.ajax({
					url: "${base}/backOrderCtl/selectInfo",
					type: "post",
					data: params,
					success: function(result){
						var dataTable = $("#pageList");
						for(var i = 0; i < result.resultList.length; i++) {
							var trClassName = ""; 
							if(i%2 == 0){
								trClassName = "list_tab_left";
							}
							var id = result.resultList[i][0];
							var name = result.resultList[i][1];
							var price = result.resultList[i][2];
							var datacount = result.resultList[i][3];
							var datatype = result.resultList[i][4];
							var startDate = result.resultList[i][5];
							var endDate = result.resultList[i][6];
							var remark = result.resultList[i][7];
							if(2 == datatype) {
								datatype = "套餐";
							} else {
								datatype = "菜品";
							}
							var row = $("<tr class='" + trClassName + "'><td>" + name + "</td><td>" + datatype + "</td><td>" + price + " 元</td>" +
								"<td>" + datacount + "</td><td>" + startDate + "</td><td>" + endDate + "</td><td>" + remark + "</td></tr>");
							dataTable.append(row);
						}
						$("#pageList tr:even").addClass("bg_color");
						loadPage(result.totalCount, result.pageSize, result.pageCurrent);
					}
				});
			};
			
			$(function() {
				onPageChange(1);
				
				$("#queryBtn").bind("click",function(){
					if($.formValidator.pageIsValid("1")) {
						var pageNumber = $("#pageNumber").val();
						onPageChange(pageNumber);
					}
				});
				
				//验证信息
				$.formValidator.initConfig({
					formID: "queryForm",
					debug:false,
					onError: function(msg, obj, errorlist){
					}
				});
				$("#name").formValidator({empty:true, onShow:"请输入名称", onCorrect:""}).inputValidator({max:25, onError:"你输入的菜名太长"}).regexValidator({regExp: "Illegal", dataType:"enum", onError:"菜名中包含非法字符"});
				$("#priceMin").formValidator({empty:true, tipID:"priceMinTip", onShow: "请输入数字", onCorrect: "" }).inputValidator({min:0, max:9999, type:"value", onErrorMin:"你输入的值必须大于等于0", onError:"单价必须在0-9999之间，请确认"}).compareValidator({desEmpty:true, desID:"priceMax", dataType:"number", operateor:"<=", onError:"起始单价不能大于结束单价"}).defaultPassed();
				$("#priceMax").formValidator({empty:true, tipID:"priceMaxTip", onShow: "请输入数字", onCorrect: "" }).inputValidator({min:0, max:9999, type:"value", onErrorMin:"你输入的值必须大于等于0", onError:"单价必须在0-9999之间，请确认"}).compareValidator({desEmpty:true, desID:"priceMin", dataType:"number", operateor:">=", onError:"结束单价不能小于起始单价"}).defaultPassed();
			});
		</script>
	</head>
	
	<body>
		<div class="cms_right">
		  	<div class="cms_title">
		    	<span>订单管理：详情</span>
		    </div>
			    <div class="cms_search">
	    			<form id="queryForm" >
						<table width="1000" border="0" class="search_bd">
							<tr>
					            <td class="yh_name">名称：</td>
					            <td class="yh_bd"><input type="text" id="name" class="cms_text02" maxlength="25"/></td>
					            <td class="tishi"><div id=""name"Tip" style="width:200px"></div></td>
					            <td class="yh_name">类型：</td>
					            <td class="yh_bd">
					            	<select id="datatype">
					            		<option value="" selected>=请选择=</option>
					            		<option value="1">菜品</option>
					            		<option value="2">套餐</option>
					            	</select>
					            </td>
					            <td class="tishi"></td>
							</tr>
							<tr>
					            <td class="yh_name">起始单价：</td>
					            <td class="yh_bd"><input type="text" id="priceMin" class="cms_text02" maxlength="6"/></td>
					            <td class="tishi"><div id="priceMinTip" style="width:200px"></div></td>
					            <td class="yh_name">结束单价：</td>
					            <td class="yh_bd"><input type="text" id="priceMax" class="cms_text02" maxlength="6"/></td>
					            <td><div id="priceMaxTip" style="width:200px"></div></td>
							</tr>
							<tr>
								<td><input type="hidden" id="orderId" value="${orderId}" /></td>
								<td align="right"><input type="reset" class="search_btn" value="重置" /></td>
								<td align="center" ><input type="button" id="queryBtn" class="search_btn" value="搜索" /></td>
								<td><input type="button" id="queryBtn" class="search_btn" value="返回" onclick="location.href='${base }/background/order/orderlist.jsp'" /></td>
								<td></td>
								<td></td>
							</tr>
				        </table>
		   			</form>
			    </div>
			<div class="grid-view">
				<table id="pageList" class="items" width="100%" border="1" cellspacing="0" cellpadding="0">
					<tr class="list_tab_title">
						<td bgcolor="#eae9eb">菜名</td>
						<td bgcolor="#eae9eb">类型</td>
						<td bgcolor="#eae9eb">单价</td>
						<td bgcolor="#eae9eb">数量</td>
						<td bgcolor="#eae9eb">起始时间</td>
						<td bgcolor="#eae9eb">结束时间</td>
						<td bgcolor="#eae9eb">备注</td>
					</tr>
				</table>
				<div id="page" style="margin: auto;"></div>
			</div>
		</div>
	</body>
</html>
	